home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
LANG
/
C
/
LIB
/
UNIXLIB37B
/
!UnixLib37
/
src
/
time
/
c
/
ftime
< prev
next >
Wrap
Text File
|
1996-11-09
|
1KB
|
62 lines
/****************************************************************************
*
* $Source: /unixb/home/unixlib/source/unixlib37/src/time/c/RCS/ftime,v $
* $Date: 1996/10/30 21:57:16 $
* $Revision: 1.1 $
* $State: Rel $
* $Author: unixlib $
*
* $Log: ftime,v $
* Revision 1.1 1996/10/30 21:57:16 unixlib
* Initial revision
*
***************************************************************************/
static const char rcs_id[] = "$Id: ftime,v 1.1 1996/10/30 21:57:16 unixlib Rel $";
/* time.c.ftime.
Function implementation for <sys/timeb.h>.
Written by Nick Burrett, 6 October 1996. */
#include <sys/timeb.h>
#include <sys/time.h>
#include <errno.h>
/* Fill in timebuf with information about the current time. */
int
ftime (struct timeb *timebuf)
{
int temp;
struct tm *tp;
/* Save the errno because it could change in the forthcoming
function calls. */
temp = errno;
/* Reset errno so we can look for a possible error in time(). */
errno = 0;
if (time (&timebuf->time) == (time_t) -1 || errno != 0)
/* Time is not available. */
return -1;
/* On RISC OS we don't support milliseconds. */
timebuf->millitm = 0;
tp = localtime (&timebuf->time);
if (tp == NULL)
return -1;
/* Specify if DST was used. */
timebuf->dstflag = tp->tm_isdst;
/* Calculate the minutes west of GMT. */
timebuf->timezone = tp->tm_gmtoff / 60;
/* Restore the original errno state. */
errno = temp;
return 0;
}